<?php
include_once('common/header.php');	
if($AppUI->id <=0) {
	Vfriend_Function::redirect(HOST_VFRIEND);
}
$strRefer	= isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$strSecret	= $AppUI->id .'_'. $intTargetId;
$strToken	= $objRequest->getParam('token','');
$strSession	= isset($_SESSION['checkout' . $strSecret]) ? $_SESSION['checkout' . $strSecret] : null;
$intError	= 0;
if(Vfriend_Function::isValidLink($strRefer) && isset($strSession) && $strToken == $strSession) {
	unset($_SESSION['checkout' . $strSecret]);
	$objProduct	= new Product();	
	$intError 	= $objProduct->checkoutBasket($AppUI->id, $intTargetId, $AppUI->fullhouseid);
	if($intError == 0) {
		if($intTargetId == 0)
			$strMessage	= $arrMessage[2];
		else {
			$strMessage	= $arrMessage[3];
			$strMessage	= str_replace('[strTarget]', $strTargetName, $strMessage);
		}
		Vfriend_Function::setMsg($strMessage);
		Vfriend_Function::redirect(LINK_PRODUCT);
	} else {
		$intError = $intError + 7;
	}
} else {
	$intError = 7;
}
if($intError > 0) {
	$strError = $arrError[$intError];	
	Vfriend_Function::setError($strError);	
}
Vfriend_Function::redirect(isset($strRefer) ? $strRefer : LINK_PRODUCT);
?>